package com.zkca.xf.ui.activity.me;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.zkca.xf.Constants_SP;
import com.zkca.xf.R;
import com.zkca.xf.base.BaseTitleActivity;
import com.zkca.xf.ui.activity.IpSettingActivity;
import com.zkca.xf.ui.activity.MainActivity;
import com.zkca.xf.utils.SPUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class IP_PortActivity extends BaseTitleActivity {

    @BindView(R.id.ip_text)
    TextView ipText;
    @BindView(R.id.port_text)
    TextView portText;
    @BindView(R.id.shezhi)
    Button shezhi;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ip__port);
        ButterKnife.bind(this);
        setTitleText("IP信息");
        setleftTextVisibility(true);
        setleftImgVisibility(true);
        String IP = SPUtil.getString(mContext, Constants_SP.IP);
        String PORT = SPUtil.getString(mContext, Constants_SP.PORT);
        ipText.setText(IP);
        portText.setText(PORT);

    }




    @OnClick(R.id.shezhi)
    public void onViewClicked() {
        final AlertDialog.Builder normalDialog =
                new AlertDialog.Builder(mContext);
        normalDialog.setTitle("IP端口配置");
        normalDialog.setMessage("点击“继续”您将清除现有的IP端口配置，并需要重新配置IP以及端口，请谨慎操作");
        normalDialog.setPositiveButton("继续", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                SPUtil.RemoveString(mContext, Constants_SP.SERVER_ADDRESS);
                SPUtil.putString(mContext,Constants_SP.USER_ID, "");
                SPUtil.putString(mContext,Constants_SP.ORG_ID, "");


                SPUtil.putInt(mContext,Constants_SP.DEPID, -199);
                startActivity(new Intent(mContext,IpSettingActivity.class));

                finish();
            }
        });
        normalDialog.setNegativeButton("返回",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        // 显示
        normalDialog.show();
    }
}
